package com.smartboot.plus.features.ssl;

import com.smartboot.plus.plugins.AbstractFeature;
import org.smartboot.socket.extension.plugins.SslPlugin;
import org.smartboot.socket.extension.ssl.factory.PemServerSSLContextFactory;
import tech.smartboot.mqtt.plugin.spec.BrokerContext;

public class MqttSslFeatures extends AbstractFeature {
	public MqttSslFeatures(BrokerContext context) {
		super(context);
	}

	@Override
	public String name() {
		return "ssl";
	}

	@Override
	public void start() throws Exception {
		SslPlugin sslPlugin = null;
		//sslPlugin = new SslPlugin<>(new ServerSSLContextFactory(getClass().getClassLoader().getResourceAsStream("server.keystore"), "123456", "123456"), ClientAuth.REQUIRE);
		sslPlugin = new SslPlugin<>(new PemServerSSLContextFactory(getClass().getClassLoader().getResourceAsStream("localhost-full.pem")));
		//sslPlugin = new SslPlugin<>(new ClientSSLContextFactory(getClass().getClassLoader().getResourceAsStream("server.keystore"),"123456"));
		context.Options().addPlugin(sslPlugin);

	}
}
